package com.czy.config;

import javax.jms.ConnectionFactory;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;

/**
 * 如果为false代表监听队列、如果为true代表监听主题
 *
 * 一个项目里既可以监听队列和主题
 */
@Configuration
public class JmsContainerFaoctoryConfig {

//	@Autowired
//	ConnectionFactory connectionFactory;

	@Bean("jmsTopicContainerFacotory")
	public DefaultJmsListenerContainerFactory jmsTopicContainerFacotory(ConnectionFactory connectionFactory) {
		DefaultJmsListenerContainerFactory containerFactory=new DefaultJmsListenerContainerFactory();
		containerFactory.setConnectionFactory(connectionFactory);
		//设置对主题的监听
		containerFactory.setPubSubDomain(true);
		return containerFactory;
	}
}
